#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 * 2 * 11 + 10;
const int M = N << 1;
typedef pair<int, int> PII;
const int INF = 0x3f3f3f3f;
int e[M], h[N], idx, w[M], ne[M];
void add(int a, int b, int c) {
  e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx++;
}
int dist[15][N], st[15][N];
int n, m, s, t, k;
void dijkstra() {
  priority_queue<PII, vector<PII>, greater<>> q;
  dist[0][s] = 0;
  q.push({0, s});

  while (q.size()) {
    int u = q.top().second;
    q.pop();

    int r = u / n;
    u %= n;
    if (st[r][u]) continue;
    st[r][u] = true;

    for (int i = h[u]; ~i; i = ne[i]) {
      int j = e[i];
      if (st[r][j]) continue;
      if (dist[r][j] > dist[r][u] + w[i]) {
        dist[r][j] = dist[r][u] + w[i];
        q.push({dist[r][j], j + r * n});
      }
    }

    if (r < k) {
      for (int i = h[u]; ~i; i = ne[i]) {
        int j = e[i];
        if (st[r + 1][j]) continue;
        if (dist[r + 1][j] > dist[r][u]) {
          dist[r + 1][j] = dist[r][u];
          q.push({dist[r + 1][j], j + (r + 1) * n});
        }
      }
    }
  }
}
int main() {
  while (~scanf("%d%d%d", &n, &m, &k)) {
    memset(h, -1, sizeof(h));
    memset(dist, 0x3f, sizeof(dist));
    memset(st, false, sizeof(st));
    idx = 0;

    scanf("%d%d", &s, &t);
    while (m--) {
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      add(a, b, c), add(b, a, c);
    }
    dijkstra();

    int ans = INF;
    for (int i = 0; i <= k; ++i) {
      ans = min(ans, dist[i][t]);
    }
    printf("%d\n", ans);
  }
}
